<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*" import="com.dr.pojo.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>UserList</title>
<!-- ================================= CSS ===========================================  -->
<style type="text/css">
	*{
		font-size: 16px;
		margin: 0;
		padding: 0;
	}
	div{
		width: 1000px;
		margin: 0 auto;
		margin-top: 10px;
	}
	td{
		padding: 5px;
	}
	h4{
		margin-bottom: 5px;
	}
	p{
		padding: 5px;
		margin-bottom: 5px;
	}
	input{
		padding: 3px;
	}
	select{
		padding: 3px;
		width: 100px;
	}
	span{
		padding: 3px;
	}
</style>

<!-- ================================= JavaScript ===========================================  -->
<script type="text/javascript" src="/lib/jquery-3.4.1.js"></script>
<script>
	$(function(){
		$('#btnSubmit').click(function(){
			if(chkPassword() && chkAccount() && chkName()){
				$('#frm').attr("action","/um/doAdd");
				$('#frm').submit();
			}
		})		
	})
	
	//	验证密码
	function chkPassword(){
		var pwdValue = $('#pwd').val();
		var cfmPwdValue = $('#cfmPwd').val();
		if(pwdValue==""){
			alert("密码不能为空！");
			return false;	
		}else if(pwdValue != cfmPwdValue){
			alert("两次输入的密码必须一致！");	
			return false;
		}else{
			return true;
		}
	}

	//	验证系统账户
	function chkAccount(){
		var accountValue = $('#account').val();
		if(accountValue == null || accountValue == ""){
			alert("系统账户不能为空！");
			return false;
		}else{
			return true;
		}
	}

	//	验证用户名
	function chkName(){
		var nameValue = $('#name').val();
		if(nameValue == null || nameValue == ""){
			alert("用户名不能为空！");
			return false;
		}else{
			return true;
		}
	}
	
</script>
</head>

<!-- ================================= Body ===========================================  -->
<body>
	<div>
		<h4>系统用户新增</h4>
		<form id="frm">
			<table>
				<tr>
					<td align="right">系统账户：</td>
					<td align="left"><input type="text" name="account" id="account"></td>			
					<td>
						<span Style="color:red"><%=request.getAttribute("attrInfoUserAdd")==null?"":request.getAttribute("attrInfoUserAdd")%></span>
					</td>	
				</tr>
				<tr>
					<td align="right">用户名：</td>
					<td align="left"><input type="text" name="name" id="name"></td>				
				</tr>
				<tr>
					<td align="right">密码：</td>
					<td align="left"><input type="password" name="password" id="pwd" ></td>				
				</tr>
				<tr>
					<td align="right">密码确认：</td>
					<td align="left"><input type="password" id="cfmPwd"></td>				
				</tr>
				<tr>
					<td align="right">岗位：</td>
					<td align="left">			
						<select id="job" name="job">
							<option>院长</option>
							<option>医生</option>
							<option>护士</option>
							<option>划价</option>
							<option>药房</option>
							<option>超级用户</option>
						</select>		
					</td>								
				</tr>
				<tr>
					<td align="right">部门：</td>
					<td align="left">
						<select id="deptId" name="deptId">
						<%
							List <Dept> list = (List)request.getAttribute("deptList");
							for(Dept dept: list){
								%>
								<option value="<%=dept.getDeptId() %>"><%=dept.getDeptName() %></option>
								<%
							}
						%>
						</select>
					</td>				
				</tr>
				<tr>
					<td align="right">账户启用：</td>
					<td align="left"><input type="checkbox" name="enable" value="1" checked></td>				
				</tr>
				<tr>
					<td align="center" colspan="2">
						<input type="button" value="提交" id="btnSubmit">
						<input type="reset" value="重写">
					</td>				
				</tr>		
			</table>
		</form>
		
	</div>
</body>
</html>